// Glinski Chess // Copyright 2020, Jay M. Coskey, except functions drawn from Chess.lud, as noted //---------------------------------------- // General functions //---------------------------------------- // Source: Chess.lud - CaptureToPieceAndResetCounter (define "CaptureToPieceAndResetCounter" (apply (if ("IsEnemyAt" (to)) (remove (to) (then (set Counter)) ) ) ) ) // Usage: ("Directions" ) (define "Directions" ("P12" (directions #1) (directions #2)) ) (define "IsToEmpty" (is In (to) (sites Empty)) ) (define "IsToEmptyOrEnemy" (or "IsToEmpty" ("IsEnemyAt" (to)) ) ) // Usage: ("P12" ) (define "P12" (if (is Mover P1) #1 #2) ) // Usage: ("SlideCaptureMove" ) (define "SlideCaptureMove" (move Slide #1 (to if:("IsEnemyAt" (to)) "CaptureToPieceAndResetCounter" ) #2 ) ) //---------------------------------------- // King movement //---------------------------------------- // Usage: ("KingCaptureStep" ) (define "KingCaptureStep" (move Step #1 (to if:"IsToEmptyOrEnemy" "CaptureToPieceAndResetCounter" ) #2 ) ) //---------------------------------------- // Pawn movement // Note: Counter is reset in (piece "Pawn" ...). //---------------------------------------- (define "IsFromInStartCell" (is In (from) (sites Start (piece (what at:(from))))) ) // Source: Derived from Chess.lud - DoubleStep // Usage: ("PawnHop" ) (define "PawnHop" (move Hop #1 (between if:(is In (between) (sites Empty))) (to if:"IsToEmpty") (then (and { (set Pending (ahead (last To) #2)) (set Var (last To)) }) ) ) ) (define "PawnCapture_Ortho" ("PawnStep_To" ("Directions" {WNW ENE} {WSW ESE})) ) (define "PawnStep_Double" ("PawnHop" Forward Backward)) // Usage: ("PawnStep_To" ) (define "PawnStep_To" ("StepToEnemy" #1)) //---------------------------------------- // Pawn Movement: En passant // - Save skipped-over spaces in Pending // - Save location of last-moved Pawn in Var. // Note: Counter is reset in (piece "Pawn" ...). //---------------------------------------- // Usage: ("EnPassant_Base" ) (define "EnPassant_Base" (move Step #1 (to if:"IsEnPassantCapture") (then (remove (var))) ) ) (define "EnPassant_Ortho" ("EnPassant_Base" ("Directions" {WNW ENE} {WSW ESE})) ) (define "IsEnPassantCapture" (and (is Pending) (= (to) (value Pending)) ) ) //---------------------------------------- // Pawn promotion //---------------------------------------- // Usage: ("PromoteTo" ) (define "PromoteTo" (move Promote (last To) #1 Mover) ) //------------------------------------------------------------------------------ (game "Glinski Chess" ("TwoPlayersNorthSouth") (equipment { (board (rotate 90 (hex 6))) (piece "King" Each ("KingCaptureStep" All ~)) (piece "Queen" Each ("SlideCaptureMove" All ~)) (piece "Rook" Each ("SlideCaptureMove" Orthogonal ~)) (piece "Bishop" Each ("SlideCaptureMove" Diagonal ~)) (piece "Knight" Each (move Leap "KnightWalk" (to if:"IsToEmptyOrEnemy" "CaptureToPieceAndResetCounter" ) ) ) (piece "Pawn" Each (or { "StepForwardToEmpty" (if "IsFromInStartCell" "PawnStep_Double") "PawnCapture_Ortho" "EnPassant_Ortho" } (then (and (if (is In (last To) (sites Mover "PromotionZone")) (moveAgain) ) (set Counter) ) ) ) ) (regions "PromotionZone" P1 (union (sites Side NW) (sites Side NE))) (regions "PromotionZone" P2 (union (sites Side SW) (sites Side SE))) (regions "Region-Dark" (sites Phase 0)) (regions "Region-Light" (sites Phase 2)) (regions "Region-Medium" (sites Phase 1)) }) (rules (start { (place "King1" coord:"B1") (place "Queen1" coord:"A2") (place "Rook1" {"A4" "D1"}) (place "Bishop1" {"A1" "B2" "C3"}) (place "Knight1" {"A3" "C1"}) (place "King2" coord:"K10") (place "Queen2" coord:"J11") (place "Rook2" {"H11" "K8"}) (place "Bishop2" {"K11" "J10" "I9"}) (place "Knight2" {"I11" "K9"}) (place "Pawn1" ) (place "Pawn2" ) }) phases:{ (phase "Movement" (play (if ("SameTurn") ("PromoteTo" (piece {"Queen" "Rook" "Bishop" "Knight"})) (do (forEach Piece) ifAfterwards:(not ("IsInCheck" "King" Mover)) ) ) ) (end { ("Checkmate" "King") (if (or (no Moves Mover) (= (counter) 100) ) (result Mover Draw) ) }) ) } ) ) //------------------------------------------------------------------------------ (option "Placement of Pawns" args:{ } { (item "Standard Pawn positions" < {"A5" "B5" "C5" "D5" "E5" "E4" "E3" "E2" "E1"} > < {"G11" "G10" "G9" "G8" "G7" "H7" "I7" "J7" "K7"} > "Pawns in the starting position chosen by Władysław Gliński in 1936" )* (item "3 Pawns shifted one space" < {"A5" "B5" "C5" "C4" "D4" "D3" "E3" "E2" "E1"} > < {"G11" "G10" "G9" "H9" "I9" "I8" "I7" "J7" "K7"} > "Glinski Chess with 3 Pawns shifted one space toward the board's edge" ) (item "5 Pawns shifted one space" < {"A5" "B5" "B4" "C4" "D4" "D3" "D2" "E2" "E1"} > < {"G11" "G10" "H10" "H9" "I9" "I8" "J8" "J7" "K7"} > "Glinski Chess with 5 Pawns shifted one space toward the board's edge" ) } ) //------------------------------------------------------------------------------ (metadata (info { (description "A chess variant played on a board made of hexagons. invented in 1936 by Władysław Gliński, and first launched in 1949. It is the most popular variant of hexagonal chess.") (aliases {"Gliński's Chess" "Glinski's Chess" "Hexagonal Chess"}) (rules "Glinski Chess is played on a hexagonal board with each side having length 6, and each space oriented horizontally. The board has 91 spaces. Piece Movement: * Kings can move one space in any of the 12 directions from the current space. There is no castling. * Rooks can slide in any of the six 'adjacent' directions from their current space---North, South, or 60 degrees off either of those. * Bishops can slide in the six 'diagonal' directions: West, East, or 30 degrees off due North or 30 degrees off due South. Note that, given the 3-colour colouring of the board, each of the three Bishops remains on the same colour that it started the game on. * Queens can make any move that would be available to a Rook or a Bishop on the current space. * Knights can leap to any space that is two spaces away in an adjacent direction (North, South, or 60 degrees off either of those), plus one more space 60 degrees off of that direction. Note that a Knight always moves to a space of a different colour than the space it moved from. * Pawns can advance one space forward without capturing. They capture by moving to one of the two adjacent spaces 60 degrees left or right of forward. A Pawn on a Pawn start space can advance two spaces forward without capturing, even if it has previously moved (by capturing) to a different Pawn start space than it started the game on. A Pawn can capture an opponent Pawn 'en passant' if the opponent Pawn just advanced two spaces on its previous turn, and the capture direction of the current player's Pawn lands it on the space that the opponent Pawn just skipped over. On reaching the farthest rank in a given file, Pawns are promoted to a Queen, Rook, Bishop, or Knight, as the player chooses. The game ends on a checkmate or stalemate. By convention, the player that causes the stalemate is awarded 3/4 of a point, while the other player is awarded 1/4 of a point. Variations: Shift the innermost 3 or 5 Pawns toward the edge of the board by one space, as proposed in A Player's Guide to Table Games, by John Jackson, Stackpole Books, 1975.") (id "855") (source "For a comparison of popular versions of hexagonal chess, see Wikipedia. For more details on other chess variants, see The Classified Encyclopedia of Chess Variants, by D. B. Pritchard (2nd edition, completed and edited by John Beasley, 2007).") (version "1.3.12") (classification "board/war/replacement/checkmate/chess") (author "Władysław Gliński") (credit "Jay Coskey, with some small functions drawn from Chess.lud, by Eric Piette") (date "1936") } ) (graphics { (piece Scale "Pawn" 0.7) (piece Scale "King" 0.8) (piece Scale "Knight" 0.8) (piece Scale "Queen" 0.8) (piece Scale "Bishop" 0.8) (piece Scale "Rook" 0.8) (board Style Chess) (region Colour "Region-Dark" (colour "#b5651d")) (region Colour "Region-Light" (colour "#fff8dc")) (region Colour "Region-Medium" (colour "#daae7c")) }) (ai "Glinski Chess_ai" ) )